﻿using System;
namespace Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="soidukiandmed2tulem", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(Soidukiandmed2tulem))]
    public class Soidukiandmed2tulemSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected ISoidukiandmed2tulem clazz;
        
        public Soidukiandmed2tulemSerializer(ISoidukiandmed2tulem clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("mark");
            if (clazz.Mark!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Mark))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("mudel");
            if (clazz.Mudel!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Mudel))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("reg_mrk");
            if (clazz.RegMrk!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.RegMrk))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("vinkood");
            if (clazz.Vinkood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Vinkood))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("mootvms");
            if (clazz.Mootvms!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Mootvms))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("reg_mass");
            if (clazz.RegMass!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.RegMass))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("istearv");
            if (clazz.Istearv!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Istearv))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("kateg");
            if (clazz.Kateg!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kateg))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("regtun");
            if (clazz.Regtun!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Regtun))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("kerenm");
            if (clazz.Kerenm!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kerenm))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("registris");
            if (clazz.Registris!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Registris))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("isikud");
            if (clazz.Isikud!=null) {
                global::Xtee.Core.SerializationMetadata metaIsikud = this.GetMetaData(clazz.Isikud);
                Writer.WriteTypeAttribute(metaIsikud.TypeQualifiedName.Namespace, metaIsikud.TypeQualifiedName.Name);
                metaIsikud.NewSerializer(clazz.Isikud).WriteXml(Writer);
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "mark")) {
                goto mark;
            }
            else {
                if ((Reader.LocalName == "mudel")) {
                    goto mudel;
                }
                else {
                    if ((Reader.LocalName == "reg_mrk")) {
                        goto reg_mrk;
                    }
                    else {
                        if ((Reader.LocalName == "vinkood")) {
                            goto vinkood;
                        }
                        else {
                            if ((Reader.LocalName == "mootvms")) {
                                goto mootvms;
                            }
                            else {
                                if ((Reader.LocalName == "reg_mass")) {
                                    goto reg_mass;
                                }
                                else {
                                    if ((Reader.LocalName == "istearv")) {
                                        goto istearv;
                                    }
                                    else {
                                        if ((Reader.LocalName == "kateg")) {
                                            goto kateg;
                                        }
                                        else {
                                            if ((Reader.LocalName == "regtun")) {
                                                goto regtun;
                                            }
                                            else {
                                                if ((Reader.LocalName == "kerenm")) {
                                                    goto kerenm;
                                                }
                                                else {
                                                    if ((Reader.LocalName == "registris")) {
                                                        goto registris;
                                                    }
                                                    else {
                                                        if ((Reader.LocalName == "isikud")) {
                                                            goto isikud;
                                                        }
                                                        else {
                                                            return;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        mark:
            if ((Reader.IsElementNil() == false)) {
                clazz.Mark = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("mark")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        mudel:
            if ((Reader.IsElementNil() == false)) {
                clazz.Mudel = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("mudel")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        reg_mrk:
            if ((Reader.IsElementNil() == false)) {
                clazz.RegMrk = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("reg_mrk")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        vinkood:
            if ((Reader.IsElementNil() == false)) {
                clazz.Vinkood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("vinkood")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        mootvms:
            if ((Reader.IsElementNil() == false)) {
                clazz.Mootvms = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("mootvms")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        reg_mass:
            if ((Reader.IsElementNil() == false)) {
                clazz.RegMass = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("reg_mass")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        istearv:
            if ((Reader.IsElementNil() == false)) {
                clazz.Istearv = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("istearv")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        kateg:
            if ((Reader.IsElementNil() == false)) {
                clazz.Kateg = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kateg")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        regtun:
            if ((Reader.IsElementNil() == false)) {
                clazz.Regtun = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("regtun")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        kerenm:
            if ((Reader.IsElementNil() == false)) {
                clazz.Kerenm = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kerenm")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        registris:
            if ((Reader.IsElementNil() == false)) {
                clazz.Registris = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("registris")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        isikud:
            if ((Reader.IsElementNil() == false)) {
                global::Xtee.Core.SerializationMetadata metaIsikud = this.GetMetaData<Soidukiandmed2tulem.IIsikudType>(Reader, ">>soidukiandmed2tulem>isikud", "http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister");
                clazz.Isikud = metaIsikud.NewEntity<Soidukiandmed2tulem.IIsikudType>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("isikud");
                    metaIsikud.NewSerializer(clazz.Isikud).ReadXml(Reader);
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                Reader.Skip();
            }
            goto START;
        }
        
        [global::Xtee.Core.Attributes.XmlTypeAttribute(Name=">>soidukiandmed2tulem>isikud", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(Soidukiandmed2tulem.IsikudType))]
        public class IsikudTypeSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
            
            protected Soidukiandmed2tulem.IIsikudType clazz;
            
            public IsikudTypeSerializer(Soidukiandmed2tulem.IIsikudType clazz) {
                this.clazz = clazz;
            }
            
            public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
                base.WriteXml(Writer);
                for (int x = 0; ((clazz.Isik != null) 
                            && (x < clazz.Isik.Count)); x = (x + 1)) {
                    if (clazz.Isik[x]!=null) {
                        Writer.WriteStartElement("isik");
                        global::Xtee.Core.SerializationMetadata metaIsik = this.GetMetaData(clazz.Isik[x]);
                        Writer.WriteTypeAttribute(metaIsik.TypeQualifiedName.Namespace, metaIsik.TypeQualifiedName.Name);
                        metaIsik.NewSerializer(clazz.Isik[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            
            public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
                base.ReadXml(Reader);
                if (Reader.LocalName=="isik") {
                    clazz.Isik = new System.Collections.Generic.List<global::Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister.ISoidukiandmed2isikTulem>();
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "isik")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>soidukiandmed2tulem>isikud>isik");
                        }
                        global::Xtee.Core.SerializationMetadata metaIsik = this.GetMetaData<global::Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister.ISoidukiandmed2isikTulem>(Reader, "soidukiandmed2isik_tulem", "http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister");
                        global::Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister.ISoidukiandmed2isikTulem item = metaIsik.NewEntity<global::Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister.ISoidukiandmed2isikTulem>();
                        clazz.Isik.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("isik");
                            metaIsik.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                }
            }
        }
    }
}
